package leetcode.lt100;

class Solution_50 {

	public double myPow(double x, int n) {
		if (n == 0)
			return 1;
		if (n == 1)
			return x;
		int temp = n / 2;
		if (n < 0) {
			temp = -temp;
			x = 1 / x;
		}
		double res = myPow(x, temp);
		if (n % 2 == 0)
			return res * res;
		return res * res * x;
	}
}
